package com.scorpio.controller.agentuser;

import com.scorpio.agentuser.domain.AgentUserEntity;
import com.scorpio.agentuser.service.AgentIncomeService;
import com.scorpio.common.core.controller.BaseController;
import com.scorpio.common.core.domain.Result;
import com.scorpio.security.annotation.PersonalLogin;
import com.scorpio.security.annotation.PersonalLoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/api/income")
public class AgentIncomeController extends BaseController {

    @Autowired
    private AgentIncomeService incomeServer;

    @PersonalLogin
    @GetMapping("statistics")
    public Result statistics(@PersonalLoginUser AgentUserEntity agent, Integer type, Date quertDate) {
        return Result.success(incomeServer.statistics(agent.getId(), type, quertDate));
    }

    @GetMapping("updateAllIncome")
    public Result updateAllIncome() {
        incomeServer.updateAllIncome();
        return Result.success();
    }
}
